<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\common\model\jia;

use cores\BaseModel;
use think\model\relation\HasOne;
use think\model\relation\HasMany;
use think\model\relation\BelongsTo;

/**
 * 商家门店店员模型
 * Class Clerk
 * @package app\common\model\store
 */
class Contract extends BaseModel
{
    // 定义表名
    protected $name = 'order_contract';

    // 定义主键
    protected $pk = 'id';
    // 追加字段
    protected $append = ['pdfUrl'];

    public function getPdfUrlAttr($value, $data)
    {
        return base_url() . $data['path'].'?t='.time();
       
    }

    public static function detail($where, $with = [])
    {
        return static::get($where, $with);
    }
    public function order(): BelongsTo
    {
        $model = "app\\common\\model\\Order";
        return $this->belongsTo($model, 'order_id', 'order_id');
    }
    public function idcardUrl(): HasOne
    {
        return $this->hasOne("app\\common\\model\\UploadFile", 'file_id', 'idcard1')
            ->bind(['idcard1_url' => 'preview_url']);
    }

     public function idcardUrl2(): HasOne
    {
        return $this->hasOne("app\\common\\model\\UploadFile", 'file_id', 'idcard2')
            ->bind(['idcard2_url' => 'preview_url']);
    }

}
